<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script th:inline="javascript">
        $(function () {
            $.getJSON('/CarType',function (result) {
                let Type=[[${getId.carType}]]
                $("[name=carType]").append("<option value=''>请选择</option>");
                for(let cartype of result){
                   if(cartype.tid == Type){
                       $("[name=carType]").append("<option selected value='"+cartype.tid+"'>"+cartype.name+"</option>");
                   }else {
                       $("[name=carType]").append("<option value='"+cartype.tid+"'>"+cartype.name+"</option>");
                   }
                }
            })
        })
    </script>
</head>
<body>
<form th:action="@{/cars/update}" method="post">
    <h3>修改</h3>
    <input type="hidden" name="carId" th:value="${getId.carId}">
    <table>
        <tr>
            <td>carName</td>
            <td><input th:value="${getId.carName}" name="carName"></td>
        </tr>
        <tr>
            <td>carPrice</td>
            <td><input th:value="${getId.carPrice}" name="carPrice"></td>
        </tr>
        <tr>
            <td>carMileage</td>
            <td><input th:value="${getId.carMileage}" name="carMileage"></td>
        </tr>
        <tr>
            <td>carBuyTime</td>
            <td><input type="date" th:value="${#dates.format(getId.carBuyTime,'yyyy-MM-dd')}" name="carBuyTime"></td>
        </tr>
        <tr>
            <td>carType</td>
            <td>
                <select name="carType" ></select>
            </td>
        </tr>
        <tr>
            <td>carStatus</td>
            <td><input th:value="${getId.carStatus}" name="carStatus"></td>
        </tr>
        <tr>
            <td>
                <input type="submit" value="修改">
            </td>
        </tr>
    </table>
</form>
</body>
</html>